package com.huawei.spare.part.replace.models;

import lombok.Data;
import org.apache.commons.io.FilenameUtils;

import java.io.Serializable;


/**
 * 已下载的安装包信息
 */
@Data
public class DownloadPackage implements Serializable {

    String software;
    String version;
    String packageName;
    String url;
    String localFileUrl;


    public DownloadPackage() {
    }

    public DownloadPackage(DownloadTask task) {
        this.software = task.software.get();
        this.version = task.version.get();
        this.url = task.url.get();
        this.localFileUrl = task.getLocalFileUrl();
        if (this.localFileUrl != null) {
            this.packageName = FilenameUtils.getName(localFileUrl);
        }
    }

    public DownloadPackage(DownloadTask task, String software, String version) {
        this(task);
        this.software = software;
        this.version = version;
    }
}
